package edu.zcmu.seckill.controller;

import edu.zcmu.seckill.response.R;
import edu.zcmu.seckill.service.PayService;
import edu.zcmu.seckill.vo.PayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/seckill/pay")
public class PayController {

    @Autowired
    PayService payService;

    @PostMapping("/seckillPay")
    public R pay(@RequestBody PayVo payVo, HttpServletRequest request){
        Boolean is=payService.pay(payVo,request);
        if (is==null){
            return R.error().message("支付失败");
        }else{
            return R.ok();
        }

    }

}
